<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../rest.js"></script>
</head>

<body>

</body>
<script>
    function getString(url) {
        return new Promise((res, rej) => {
            ajax({
                url: url,
                dataType: 'text',
                callback: function (data) {
                    res(data)
                }, error: function (data) {
                    rej(data)
                }
            })
        })
    }


    var txt1 = getString('./data/1.txt')
    var txt2 = getString('./data/2.txt')
    var txt3 = getString('./data/3.txt')

    var str = ''
    txt1.then(res => {
        str += res
        return txt2
    }).then(res => {
        str += res
        return txt3
    }).then(res => {
        str += res
        console.log(str);
    }).catch(err => {
        console.log(err)
    })
</script>

</html>